#include "qmodbusdrive.h"

#include "../../lib/shared/qdriveattribute.h"

QModbusDrive::QModbusDrive(QObject *parent):
    QAbstractDrive(parent)
{
    initAttribute();
}

QString QModbusDrive::name()
{
    return "Modbus";
}

bool QModbusDrive::addDriveMission(QDriveMission *mission)
{
    return QAbstractDrive::addDriveMission(mission);
}

void QModbusDrive::initAttribute()
{
    QDriveAttribute *attr;

    attr=new QDriveEnumAttribute("Port");
    attr->setValue("COM1");
    attr->setAttribute("Enum",QStringList()<<"COM1"<<"COM2"<<"COM3"<<"COM4"<<"COM5"
                       <<"COM6"<<"COM7"<<"COM8"<<"COM9"<<"COM10"
                       <<"COM11"<<"COM12"<<"COM13"<<"COM14"<<"COM15"
                       <<"COM16"<<"COM17"<<"COM18"<<"COM19"<<"COM20"
                       <<"COM21"<<"COM22"<<"COM23"<<"COM24"<<"COM25");
    appendAttribute(attr);

    attr=new QDriveEnumAttribute("Baud Rate");
    attr->setValue("19200");
    attr->setAttribute("Enum",QStringList()<<"4800"<<"9600"<<"19200"<<"38400"<<"57600"<<"115200");
    appendAttribute(attr);

    attr=new QDriveEnumAttribute("Parity Bit");
    attr->setValue("None");
    attr->setAttribute("Enum",QStringList()<<"None"<<"Even"<<"Odd");
    appendAttribute(attr);

    attr=new QDriveEnumAttribute("Data Bit");
    attr->setValue("8");
    attr->setAttribute("Enum",QStringList()<<"7"<<"8");
    appendAttribute(attr);

    attr=new QDriveEnumAttribute("Stop Bit");
    attr->setValue("1");
    attr->setAttribute("Enum",QStringList()<<"1"<<"2");
    appendAttribute(attr);
}
